@extends('layouts.default')
@section('main')
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/themes/default/default.css" />
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.css" />
    <script src="{{URL::asset('js/')}}/kindeditor-4.1.7/kindeditor.js" type="text/javascript"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/lang/zh_CN.js"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <script src="{{URL::asset('js/My97DatePicker/')}}/WdatePicker.js"></script>
    <script>
        KindEditor.ready(function(K) {

            var editor1 = K.create('#project_content,#project_invest_aim,#form,#project_fund_plan,#project_team_advantage，#description, #cooperate', {
                uploadJson: "{{url('kindedit/upload')}}",
                fileManagerJson: "{{url('kindedit/manager')}}",
                allowFileManager: true,
                afterBlur: function() {
                    this.sync();
                },
                items: ['source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', 'image', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'table', 'hr', 'emoticons', 'pagebreak', 'anchor', 'link', 'unlink', '|']
            });

        });
    </script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a> <a href="{{url('project/index')}}" class="tip-bottom">项目管理</a> <a href="#" class="current">新增项目</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span7" style="width:80%;">
                    <div class="widget-box">
                        <div class="widget-title">
                        <span class="icon"> <i class="icon-align-justify"></i>
                        </span>
                            <h5>基础信息</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form  action="{{url('project/insert')}}" method="post" class="form-horizontal" id="projectForm" >

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>项目名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject" value=""   />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">副标题 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="title" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>行业分类 :</label>
                                    <div class="controls">
                                        @foreach($categories as $key => $category)
                                            <input type="checkbox" name="categories[]" value="{{ $key }}">&nbsp{{$category}}
                                        @endforeach
                                    </div>
                                </div>



                                <div class="control-group">
                                    <label class="control-label">项目简介 :</label>
                                    <div class="controls">
                                        <textarea id="description" name="description" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">合作主体 :</label>
                                    <div class="controls">
                                        <textarea id="cooperate" name="cooperate" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目公司构成 :</label>
                                    <div class="controls">
                                        <textarea id="form" name="form" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">融资金额 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="invest_fund" value="" placeholder="单位：元" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目周期 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="cycle" value="" placeholder="以年为单位" />
                                    </div>
                                </div>



                                <div class="control-group">
                                    <label class="control-label">列表页底图 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="photo"
                                               placeholder="点击右边小图标上传列表页缩略图" />
                                        <img src="" width="120px" name="photo" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadPhotoBtn"   onclick="javascript:openBrowse('uploadPhotoBtn','uploadPhoto');">点击上传(图片大小不小于h:285像素×w:150像素)</a>
                                        <input type="file" id="uploadPhoto" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadPhoto','photo')"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">详情页logo :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="big_image"
                                               placeholder="点击右边小图标上传推广大图" />
                                        <img src="" width="120px" name="big_image" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadBimgBtn"   onclick="javascript:openBrowse('uploadBimgBtn','uploadBimg');">点击上传(图片大小不小于h:400像素×w:400像素)</a>
                                        <input type="file" id="uploadBimg" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBimg','big_image')"/>
                                    </div>
                                </div>



                                <div class="widget-title">
                                    <span class="icon"> <i class="icon-align-justify"></i></span>
                                    <h5>状态选项</h5>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否推荐 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="recommend" value="1"   /> 是
                                        </label> <label> <input type="radio" name="recommend" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否热门 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="hot" value="1"  /> 是
                                        </label> <label> <input type="radio" name="hot" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否置顶 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="stick" value="1" /> 是
                                        </label> <label> <input type="radio" name="stick" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否头条 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="top" value="1" /> 是
                                        </label> <label> <input type="radio" name="top" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否路演 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="is_roadshow" value="1"  /> 是
                                        </label> <label> <input type="radio" name="is_roadshow" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否向投资人公开 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="open_to_investor" value="1" checked="checked"  /> 是
                                        </label> <label> <input type="radio" name="open_to_investor" value="0"  /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">状态 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="status" value="1" checked="checked" /> 审核通过</label>
                                        <label> <input type="radio" name="status" value="0" /> 审核中</label>
                                        <label> <input type="radio" name="status" value="2" /> 审核不通过</label>
                                        <label> <input type="radio" name="status" value="-1" /> 禁用</label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否明星项目 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="star" value="1"  /> 是
                                        </label> <label> <input type="radio" name="star" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <button type="button" class="btn btn-success" id="doSave">确认创建</button>
                                    <input type="hidden" class="span11" name="type" value="ppp"   />
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script>
            $("input[name='user_search']").keydown(function(event) {
                if (event.which == "13"){
                    var param = {};
                    param['user_search'] = $(this).val();
                    ajaxRequest(param, '/project/user-search', function (data) {
                        if (data.status) {
                            var html = '<option value="">请选择</option>';
                            $.each(data.message, function (i, n) {
                                if(n.realname){
                                    html += "<option value='" + n.uid + "'>" + n.realname + "</option>";
                                }else{
                                    html += "<option value='" + n.uid + "'>" + n.nickname + "</option>";
                                }
                            });
                            $("#uid").html(html);
                            alert('恭喜，已经生成选项,请选择所需要的用户');
                        } else {
                            var html = '<option value="">请按上面输入框的说明生成选项</option>';
                            $("#uid").html(html);
                            alert(data.message);
                        }
                    });
                }
            });

            $("#doSave").click(function(){
                $(this).attr('disabled','disabled');

                var project_content = $("#project_content").html();
                $("input[name='content']").val(project_content);
                ajaxRequest($('#projectForm').serializeArray(),$('#projectForm').attr('action'),function(data){
                    if(data.status){
                        alert(data.message);
                        window.location.href = data.forwardUrl;
                    }else{
                        $("#doSave").removeAttr('disabled');

                        alert(data.message);
                    }
                });
            });

            $("#city").change(function() {
                $("#zone").empty();
                $.post("{{url('zone/children')}}", {
                    id: $(this).val()
                }, function(data) {
                    if (data.status) {
                        var html = '<option value="0">城市</option>';
                        $.each(data.message, function(i, n) {
                            html += "<option value='"+n.id+"'>"+n.name+"</option>";
                        });
                        $("#zone").html(html);
                    }
                }, 'json');
            });
        </script>
@stop
